﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TireBias.Models.BIASPLANModel.BIASPLAN_DS>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Old_ToppedCode
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <style type="text/css">
      #txtInputA, #txtInputB
      {
         font-size: 1em;
         height: 2em;
         line-height: 2.5em;
         width: 90%;
      }
      .nomat
      {
         color:Red !important;
      }
   </style>
   <table class="shadow" style="margin-left: 5%; width: 94%">
      <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._Text))
         {%>
      <tr>
         <td colspan="2" class="cell" style="font-size: x-large; margin-left: 5%; line-height: 35px;
            padding: 5px; background-color: #C38DEC; color:White">
           <%= Model._Text%>
         </td>
      </tr>
      <%} %>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px; width: 35%;">
            DATE-SEQ<br />
            <span class="fontTh">ล็อตที่ผลิต</span>
         </td>
         <td class="cell" id="seqDT">
       <h3>   <%= Model._Plandt %>-<%=Model._Itemno %></h3>  
         </td>
      </tr>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px; width: 35%;">
            SIZE<br />
            <span class="fontTh">ขนาดผ้าใบ</span>
         </td>
         <td class="cell" id="Td1">
         <h3> <%= Model._Size %></h3>  
         </td>
      </tr>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px; width: 35%;">
            FORMING
            <br />
            <span class="fontTh">เครื่องที่สร้าง</span>
         </td>
         <td class="cell" id="Td2">
        <h3>   <%= Model._Forming %></h3> 
         </td>
      </tr>
      <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._P1))
         { %>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px; width: 35%;">
            P1
            <br />
            <span class="fontTh">ความยาวผ้าใบชั้นที่ 1 (มม.)</span>
         </td>
         <td class="cell" id="Td3">
     <h3>  <%= Model._P1%></h3>     
         </td>
      </tr>
      <% } %>
      <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._P2))
         { %>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px; width: 35%;">
            P2
            <br />
            <span class="fontTh">ความยาวผ้าใบชั้นที่ 2 (มม.)</span>
         </td>
         <td class="cell" id="Td4">
        <h3>   <%= Model._P2%></h3> 
         </td>
      </tr>
      <% } %>
      <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._P3))
         { %>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px; width: 35%;">
            P3
            <br />
            <span class="fontTh">ความยาวผ้าใบชั้นที่ 3 (มม.)</span>
         </td>
         <td class="cell" id="Td5">
           <h3> <%= Model._P3%></h3>
         </td>
      </tr>
      <% } %>
      <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._P4))
         { %>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px; width: 35%;">
            P4
            <br />
            <span class="fontTh">ความยาวผ้าใบชั้นที่ 4 (มม.)</span>
         </td>
         <td class="cell" id="Td6">
          <h3> <%= Model._P4%></h3> 
         </td>
      </tr>
      <% } %>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px; width: 35%;">
            Topped Cord
            <br />
            <span class="fontTh">ผ้าใบ</span>
         </td>
         <td class="cell" id="Td7">
         <h3>  <%= Model._Topcrdcd%></h3> 
         </td>
      </tr>
      <tr class="rowa">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Topped Cord A
            <br />
            <span class="fontTh">ผ้าใบ A</span>
         </td>
         <td class="cell">
            <input type="password" id="txtInputA" cols="A" chk="" value=""   onkeydown="checkEnter($(this));"    />
         </td>
      </tr>
      </table>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="FeaturedContent" runat="server">
    <section class="featured">
 <div class="content-wrapper" style="height:40px">
            <hgroup class="title float-left">
            <h1>Bias Head Computer</h1>
                <h2  style="padding-left:55px;">BIAS NO.<%= TireBias.Models.SessionBag.Current.biasno %></h2>      
             
            </hgroup> 
             <hgroup class="title float-right">
                <h3>
         Name :
         <% if (Request.IsAuthenticated)
            { %>
         <%:  User.Identity.Name %>
         <% } %></h3>
            </hgroup>   
 </div>
 </section>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="TableContent" runat="server">
    <div class="float-left" style="margin-left: 50px;">
          <input type="button" id="back" value="BACK" class="btnFooter"  
              style="height: 75px;  width: 350px;" />
        
      </div>
</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="ScriptsSection" runat="server">
    <script type="text/jscript">
        $("#txtInputA").focus();
        function GET_Barcode(obj) {
            obj.val(obj.val().toUpperCase());
            var myArray = obj.val().split('+');
            if (!(7 >= myArray.length <= 8)) {
                //   alert(1);
                alert("ระบุค่าไม่ถูกต้อง");
                $("#txtInputA").val("");
                return false;
            }
            var pt = $.trim(myArray[6 + (myArray.length - 7)]);

            if (pt != "A") {
                alert("ระบุค่าไม่ถูกต้อง");
                $("#txtInputA").val("");
                return false;
            }
            var url = '<%= Url.Action("Get_Detail","BiasHead") %>' + '?seq=' + '<%=Model._OldSeq %>';
            $.post(url, function (data) {
                code = data[0]._topcrdcd + data[0]._Tcrdlot + data[0]._toproll;
                code2 = myArray[0] + myArray[1] + myArray[2];
             
                if (code != code2) {

                    alert("ระบุค่าไม่ถูกต้อง");
                    $("#txtInputA").val("");
                    $("#txtInputA").focus();
                    return false;
                } else {
                    Savedata();
                }

            });
            
                      
        }
        function checkEnter(obj) {
            if (event.keyCode == 13) {
                var nm = (obj.attr("id"));
                GET_Barcode(obj);
            }
        }


        $("#back").click(function () {
            var url = '<%= Url.Action("RollBack","BiasHead") %>' + '?seq=' + '<%= Model._Plandt %>' + "-" + '<%=Model._Itemno %>';
            url = url + "&st=0&biasno=" + '<%: TireBias.Models.SessionBag.Current.biasno %>' + '&shift=' + '<%: TireBias.Models.SessionBag.Current.shift %>';
            window.location = url;
        });

        function callScriptMethod(url, jsonObject, action, callback, async) {

            callback = callback || function () { };
            async = (async == null || async);

            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: url,
                data: JSON.stringify(jsonObject),
                dataType: "json",
                async: async,
                success: function (data) {

                    if (data.success != "0") {
                        var getUsersUrl = '<%= Url.Action("Use_KANBAN") %>' + '?seq=' + $.trim($("#seqDT").text()) + '&biasno=' + '<%=  TireBias.Models.SessionBag.Current.biasno  %>' + '&shift=' + '<%=  TireBias.Models.SessionBag.Current.shift %>';
                        window.location = getUsersUrl;
                    } else alert(data.message);
                },
                error: function (xhr, status, error) {
                    var err = xhr.responseText;
                    alert(err.Message);
                }

            });
        }


        function Savedata() {
            if ($("#txtInputA").val() == "") {
                return;
            }

            var myArrayA = $("#txtInputA").val().split("+");
            var reason = "";

            var dataForSubmit = new Array();
            dataForSubmit.push({
                _biasno: '<%: TireBias.Models.SessionBag.Current.biasno %>',
                _plandt: '<%: Model._Plandt %>',
                _itemno: '<%: Model._Itemno %>',
                _Topcrdcd: '<%=Model._Topcrdcd %>',
                _Empname: '<%: User.Identity.Name %>',
                _Tcrdcd: myArrayA[0],
                _Tcrdlot: myArrayA[1],
                _topexp: myArrayA[4],
                _toplen: myArrayA[6],
                _toproll: myArrayA[2],                
                _shift: '<%: TireBias.Models.SessionBag.Current.shift %>'
            });
            var getUsersUrl = '<%= Url.Action("Save_Date") %>';

            callScriptMethod(getUsersUrl, { theData: dataForSubmit }, 'ADD');
        }
          
    </script>

</asp:Content>
